import { app, BrowserWindow, dialog, ipcMain } from 'electron'
import { ioc } from './ioc'
import { NotebooksController } from './controller/NotebooksController'
import { LocalDB } from './db/DatabaseInit'
export function initBridge() {
  ipcMain.handle('createDocument', async (e, name) => {
    return await ioc.get(NotebooksController).create(name)
  })

  ipcMain.handle('getDocuments', async () => {
    return await ioc.get(NotebooksController).getAll()
  })
}

/**
 * 释放所有资源
 */
export async function destroyBridge() {
  console.log(111)
  await ioc.get(LocalDB).destroyConnectionPool()
}
